<?php
class Layout_View_Helper_MenuRenderer extends Zend_View_Helper_Abstract {
	private $_menuHelper;

  public function MenuRenderer($type = null) {

		$method = '_get' . $type;
		if(method_exists($this, $method)) {
			return $this->{$method}();
		}

		return $this->_getDefaultmenu($type);
	}

	private function _setMenuHelper() {
		$this->_menuHelper = $this->view->getHelper('navigation')->navigation()->menu();
	}

	private function _getMenuHelper() {
		if($this->_menuHelper instanceof Zend_View_Helper_Navigation_Menu === false) {
			$this->_setMenuHelper();
		}
		return $this->_menuHelper;
	}

	private function _getDefaultMenu($type) {
		$defaultmenu	= $this->_getMenuHelper()->findBy('id', $type);
		return $this->_getMenuHelper()
			->renderMenu($defaultmenu);
	}

	private function _getFootMenu() {
		$footmenu	= $this->_getMenuHelper()->findBy('id', 'footmenu');
		$partial 	= array('footmenu.phtml', 'default');

		return $this->_getMenuHelper()->renderPartial($footmenu, $partial);
	}

	private function _getHeadMenu() {
		$footmenu	= $this->_getMenuHelper()->findBy('id', 'headmenu');
		$partial 	= array('headmenu.phtml', 'default');

		return $this->_getMenuHelper()->renderPartial($footmenu, $partial);
	}
}
?>
